#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int largestDivisibleSubset(vector<int>& nums) {
    int dp[nums.size()];
    //[无后效性]每个nums[i]为必须选取的状态
    fill(dp, dp + nums.size(), 1);
    sort(nums.begin(), nums.end());
    for (unsigned int i = 1; i < nums.size(); i++) {
        for (unsigned int j = 0; j < i; j++) {
            if (nums[i] % nums[j] == 0) {
                dp[i] = max(dp[i], dp[j] + 1);
            }
        }
    }
    return *max_element(dp, dp+nums.size());
}
int main(){
    vector<int> nums = {1,2,4,8};
    cout << largestDivisibleSubset(nums) << endl;
    return 0;
}